package com.icloud.common.web.enums;

import lombok.Getter;

@Getter
public enum ResultEnum {
    SUCCESS("SUCCESS"), // 成功
    FAILED("FAILED"); // 失败

    private final String code;

    ResultEnum(String code){
        this.code = code;
    }

    public static ResultEnum byCode(String code) {
        for (ResultEnum e: ResultEnum.values()) {
            if (e.code.equalsIgnoreCase(code)) {
                return e;
            }
        }
        return null;
    }

    public static boolean isSuccess(String code){
        return SUCCESS.code.equalsIgnoreCase(code);
    }

    public static boolean isFailed(String code){
        return FAILED.code.equalsIgnoreCase(code);
    }
}
